#! /bin/sh
# Copyright 2018 Google LLC.
# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

if [ -z "$1" ]; then
    echo "Usage: $0 META.JSON" >&2
    exit 1
fi

set -x
set -e
META_JSON="$1"
cd "$(dirname "$0")/../.."

if [ -z "$SKQP_SKIP_INFRA_UPDATE" ]; then
    go get -u go.skia.org/infra/golden/go/search
fi
go run tools/skqp/make_gmkb.go \
    "$META_JSON" \
    platform_tools/android/apps/skqp/src/main/assets/gmkb
env GIT_SYNC_DEPS_QUIET=1 python tools/git-sync-deps
O='out/ndebug'
mkdir -p $O
bin/gn gen $O --args='cc="clang" cxx="clang++" is_debug=false'
ninja -C $O jitter_gms list_gpu_unit_tests
$O/jitter_gms tools/skqp/bad_gms.txt
python tools/skqp/make_rendertests_list.py
rm 'bad.txt' 'good.txt'
sh tools/skqp/upload_model
$O/list_gpu_unit_tests \
    > platform_tools/android/apps/skqp/src/main/assets/skqp/unittests.txt
